import javax.imageio.ImageIO;

/**
 * Utility class to load and hold all of the images for the game.
 * Most of the magic numbers live here.
 * @author Chris
 *
 */
public class SpriteLib {

	static Sprite DEFENDER;
	static Sprite DEFENDER_LASER;
	static Sprite BASE_COMPONENTS;
	static Sprite INVADER_LOW;
	static Sprite INVADER_MID;
	static Sprite INVADER_TOP;
	static Sprite BONUS;
	static Sprite INVADER_LASER;
	static Sprite INVADER_DEATH;
	static Sprite DEFENDER_DEATH;
	static Sprite SCORE;
	static Sprite LIVES;
	static Sprite GAME_OVER;
	static Sprite NUMBERS;
	
	public SpriteLib(){
		try{
//			say("Defender");
			DEFENDER = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprDefender.png")), 19*2, 8*2, 1);
			DEFENDER_LASER = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprDefenderLaser.png")), 3*2, 8*2, 4);
			DEFENDER_DEATH = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprDefenderDeath.png")), 19*2, 8*2, 3);
//			say("Base");
			BASE_COMPONENTS = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprBaseComponents.png")), 16, 16, 20);
//			say("invaders");
			INVADER_LOW = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprInvaderLow.png")), 16*2, 16*2, 2);
			INVADER_MID = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprInvaderMid.png")), 16*2, 16*2, 2);
			INVADER_TOP = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprInvaderTop.png")), 16*2, 16*2, 2);
			INVADER_LASER = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprInvaderLaser.png")), 3*2, 8*2, 4);
			INVADER_DEATH = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprInvaderDeath.png")), 16*2, 16*2, 3);
//			say("bonus");
			BONUS = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprBonus.png")), 17*2, 8*2, 3);
//			say("HUD");
			SCORE = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprScore.png")), 74, 14, 1);
			LIVES = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprLives.png")), 74, 14, 1);
			GAME_OVER = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprGameOver.png")), 138, 14, 1);
			NUMBERS = new Sprite(ImageIO.read(getClass().getClassLoader().getResource("sprNumbers.png")), 10, 14, 10);
		}
		catch(Exception e){
			System.out.println("Problem while loading sprites: " + e);
		}
	}
	
	static public void say(String words){
		System.out.println(words);
	}
}
